<?php

class Admin_Form_FileUpload extends Zend_Form {
    private $_dir;
    private $_extFilter;
    public function __construct($tmpDir, $extension=false){
        parent::__construct();
        $this->_dir = $tmpDir;
        $this->_extFilter = $extension===false?'jpg,png,gif,pdf,doc,docx,xls,xlsx,rar,zip,rtf,odt': $extension;
    }
	public function init(){
        parent::init();
		$translator = new Zend_Translate(
          'array',
          APPLICATION_PATH.'/../library/Nippy/languages/lang.ru.php',
          'ru',
          array('scan' => Zend_Translate::LOCALE_DIRECTORY)
        );
		Zend_Validate_Abstract::setDefaultTranslator($translator);
        
		$element = new Zend_Form_Element_File('newfile');
		//->setDestination('/var/www/upload');
		$element->setLabel('Upload an image:')
			->addValidator('Count', false, 1)
			->addValidator('Extension', false, 'jpg,png,gif,pdf,doc,docx,xls,xlsx,rar,zip,rtf,odt')
			->addFilter('Rename',$this->_dir.time().'.tmp');
		$this->addElement($element, 'newfile');
	}
}
?>